﻿using AutoMapper;
using MemorySiteServer.Models;
using Snowflake.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace MemorySiteServer.ViewModels.AccountViewModels
{
    public class RegisterRequest : BaseAPI.BaseCreateViewModel<User>
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [Required]
        [StringLength(20, MinimumLength = 3)]
        public string Name { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        [Required]
        [StringLength(32, MinimumLength = 3)]
        public string Password { get; set; }

        public override User CreateModel(IMapper mapper, IdWorker idWorker)
        {
            return new User()
            {
                ID = idWorker.NextId(),
                Name = Name,
                Password = Password,//客户端MD5加密之后的Password
                IsDeleted = true,
                // 游客
                RoleID = 2
            };
        }
    }
}
